#pragma once
#ifndef _SOLUTION_H
#define _SOLUTION_H

#include <vector>
#include <limits>
#include <iostream>

#include <boost/serialization/access.hpp>

#include "utils.h"

struct Solution
{
	friend class boost::serialization::access;

	typedef std::vector<Move> moves_t;

	moves_t moves;
	unsigned penaltySum;

	Solution(const moves_t& _m, const unsigned _pen) : moves(_m), penaltySum(_pen)
	{}

	//defaultni ctor si ulozi prazdny seznam a celkovou penalizaci
	//nejhorsi moznou..
	Solution()
	{
		penaltySum = std::numeric_limits<unsigned>::max();
	}

        bool operator<(const Solution& other) const {
            return penaltySum < other.penaltySum;
        }

	virtual ~Solution()
	{}

private:
	//////////////////////////////////////////////////////////////////////////
	// funkce poskytujici serializaci do daneho archivu
	template<class Archive>
	inline void serialize(Archive& ar, const unsigned int version)
	{
		ar & penaltySum & moves;
	}
};

std::ostream& operator<< (std::ostream& os, const Solution& sol)
{
	utils::printVector(os, sol.moves);
	os << "Total penalty = " << sol.penaltySum << "\n";
	return os;
}

#endif
